function [F, G] = grid_search(param, EPiQ0, EPiQ1, ExportProbQ, ExportCutoffQ)

    
    % payoff for each Q
    matrix_EPiQ = EPiQ0 + (EPiQ1-EPiQ0).*ExportProbQ ...
                  - exp(param.mu_E+1/2*param.sigma_E^2).*normcdf(ExportCutoffQ-param.sigma_E);

    % check
    if min(min( (EPiQ1-EPiQ0).*(ExportProbQ>0.0001) ))<0
        disp('grid search: EPiQ1-EPiQ0 < 0') 
        [(EPiQ1-EPiQ0).*(ExportProbQ>0.0001)]
    end  

    % grid search
    [payoff_opt, q_opt_index] = max(matrix_EPiQ, [], 2);            
     

    % return
    F = q_opt_index;
    G = payoff_opt;
    
end